﻿@model SimpleTaskManager.Domain.Entities.Task

@{
    ViewBag.Title = "Reports";
}

@{ Html.RenderAction("Header", new { id = Model.TaskID, page = 2}); }
<fieldset>
    <legend>Reports</legend>
    <table class="tablesorter" id="taskTable">
<thead>
        <tr>
            <th>Name</th>
            <th>Uploaded By</th>
            <th>Uploaded At</th>
            <th>Approved</th>
        </tr>
</thead>
<tbody>
        @foreach(SimpleTaskManager.Domain.Entities.ReportHeader report in ViewBag.Reports)
        {
            <tr>
                <td>@Html.ActionLink(report.Name, "ReportDetails", 
                    new { taskId = Model.TaskID, reportId = report.ReportHeaderID})</td>
                <td>@(report.CreatedBy.FirstName + " " + report.CreatedBy.LastName)</td>
                <td>@report.CreationDate.ToString("yyyy-MM-dd HH:mm:ss")</td>
                <td>@(report.IsApproved 
                ? "yes (by " + report.ApprovedBy.FirstName + " " + report.ApprovedBy.LastName + ")" 
                : "no")</td>
            </tr>
        }
</tbody>
    </table>
    @if(ViewBag.CanAddReport){
        <div class="list_button">@Html.ActionLink("Upload report", "UploadReport", new { id = Model.TaskID})</div>
    }
</fieldset>
@{ Html.RenderAction("Footer"); }
